/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package idv.cloudee.proxy2.test;

import idv.cloudee.proxy2.impl.getpost.GETPOSTModifier;
import com.cirnoworks.http.utils.HeaderRequest;
import com.cirnoworks.http.utils.HeaderResponse;
import idv.cloudee.proxy2.framework.ProxySession;
import java.io.OutputStream;
import java.util.ArrayList;
import java.util.Map.Entry;

/**
 *
 * @author Cloudee
 */
public class GETPOSTDisplayer implements GETPOSTModifier {

    public void beginRequest(ProxySession session) {
        System.out.println("Requsst======");
    }

    public HeaderRequest modifyRequest(HeaderRequest param) {
        System.out.println(param.getRequestLine());
        param.clear("Accept-Encoding");
        String key;
        for (Entry<String, ArrayList<String>> entry : param.entrySet()) {
            key = entry.getKey();
            for (String value : entry.getValue()) {
                System.out.println(key + ":" + value);
            }
        }
        return param;
    }

    public OutputStream getPOSTOutputStream(OutputStream os) {
        return new CopyOutputStream(os, System.out, true);
    }

    public HeaderResponse modifyResponse(HeaderResponse param) {
        System.out.println("Response=========\n" + param.getResponseLine());
        String key;
        for (Entry<String, ArrayList<String>> entry : param.entrySet()) {
            key = entry.getKey();
            for (String value : entry.getValue()) {
                System.out.println(key + ":" + value);
            }
        }
        return param;
    }

    public OutputStream getResponseOutputStream(OutputStream os) {
        return new CopyOutputStream(os, System.out, true);
    }

    public void requestOver() {
        System.out.println("Over");
    }
}
